<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>

		<link rel="stylesheet" type="text/css" href="../assets/css/layui.css" />
		<script src="../assets/layui.js" type="text/javascript" charset="utf-8"></script>

		<link rel="stylesheet" type="text/css" href="../js/bootstarp-3.3.7/css/bootstrap.min.css" />
		<script src="../js/jquery/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/bootstarp-3.3.7/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>

		<link rel="stylesheet" type="text/css" href="../js/bootstarp-table-1.11.1/bootstrap-table.min.css" />
		<script src="../js/bootstarp-table-1.11.1/bootstrap-table.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/bootstarp-table-1.11.1/bootstrap-table-zh-CN.min.js" type="text/javascript" charset="utf-8"></script>

	</head>
	<script>
		$(function() { //, headers: { 'x-requested-with': 'XMLHttpRequest' }
			$.ajaxSetup({
				crossDomain: true,
				xhrFields: {
					withCredentials: true
				}
			});
		});
	</script>
	<script type="text/javascript">
		layui.use('layer', function() {
			var $ = layui.jquery,
				layer = layui.layer; //Tab的切换功能，切换事件监听等，需要依赖element模块

			var id = new Array();
			$(function() {
				$("#fjf").bootstrapTable({
					url: "http://localhost:8091/add_cost",
					pagination: true,
					pageSize: 5,
					clickToSelect: true,
					//queryParams: queryParams2,
					columns: [{
						checkbox: true,
						width: 80,
					}, {
						field: 'extracharges_name',
						title: '名称',
						align: 'center',
					}, {
						field: 'fee',
						title: '金额(元)',
						align: 'center',
					}]
				})

				$("#addFjfBtn").click(function() {
					id.splice(0, id.length)
					var getSelectRows = $("#fjf").bootstrapTable('getSelections', function(row) {
						return row;
					});
					for(var i = 0; i < getSelectRows.length; i++) {
						id.push(getSelectRows[i].pre_id);
					}

					parent.$("#fjfIdStr").val(id)
					var index = parent.layer.getFrameIndex(window.name);
					parent.layer.close(index);
				})
			})

		})
	</script>

	<body>
		<div align="center">

			<button type="button" class="btn btn-danger " id="addFjfBtn"><i class="glyphicon glyphicon-ok"></i> 添加费用</button>
		</div>
		<br />
		<table id="fjf"></table>
	</body>

</html>